<?xml version="1.0" encoding="iso-8859-1"?>

<!-- 
  -- Please see the readme.txt file included with this distribution for 
  -- attribution and copyright information.
  -->

<root version="2.0">
	<!-- DISEASE -->
	<windowclass name="reference_disease">
		<frame>whitecontrolarea</frame>
		<placement>
			<size>
				<width>700</width>
				<height>300</height>
			</size>
		</placement>
		<sizelimits>
			<dynamic>
				<resize>vertical</resize>
			</dynamic>
			<minimum>
				<width>700</width>
			</minimum>
			<maximum>
				<width>700</width>
			</maximum>
		</sizelimits>
		<minimize>minimized_reference</minimize>
		<tooltip>
			<field>name</field>
		</tooltip>
		<script>
			function onInit()
				diseaselab.setColor("ffffffff")
				levellab.setColor("ffffffff")
				level.setColor("ffffffff")
				name.setColor("ffffffff")					
			end

			function buildDiseaseAttackStructures()
				local disease_node = getDatabaseNode();
				local powerattack_node = disease_node.getChild("attacks").getChild("id-00001");

				local rCreature = nil;
				local rFocus = nil;

				local rAbility = {};
				rAbility.type = "attack";
				rAbility.name = NodeManager.get(disease_node, "name", "");
				rAbility.range = "";
				rAbility.defense = NodeManager.get(powerattack_node, "attackdef", "");

				local rAbilityClause = {};
				rAbilityClause.stat = {};
				rAbilityClause.mod = NodeManager.get(powerattack_node, "attackstatmodifier", 0);

				rAbility.clauses = { rAbilityClause };

				return rCreature, rAbility, rFocus;
			end			

			function handleDoubleClick()
				local attack_name, attack_dice, attack_mod = RulesManager.buildAttackRoll(buildDiseaseAttackStructures());
				return RulesManager.dclkAction("attack", attack_mod, attack_name, nil, nil, attack_dice);
			end			

			function handleDrag(draginfo)
				local attack_name, attack_dice, attack_mod = RulesManager.buildAttackRoll(buildDiseaseAttackStructures());
				return RulesManager.dragAction(draginfo, "attack", attack_mod, attack_name, nil, attack_dice);
			end
		</script>
		<sheetdata>
			<genericcontrol name="topframe">
				<anchored>
					<top>
						<anchor>top</anchor>
						<offset>1</offset>
					</top>
					<left>
						<anchor>left</anchor>
						<offset>1</offset>
					</left>
					<right>
						<anchor>right</anchor>
						<offset>-1</offset>
					</right>
					<bottom>
						<anchor>bottom</anchor>
					</bottom>
				</anchored>
				<frame>
					<name>diseaseframe</name>
				</frame>
			</genericcontrol>
			<windowopencontrol>
				<anchored>
					<position>insidetopleft</position>
					<offset>13,8</offset>
					<size>
						<width>20</width>
						<height>20</height>
					</size>
				</anchored>
				<icon>
					<normal>button_openwindow</normal>
					<pressed>button_emptytarget</pressed>
				</icon>
				<class>reference_disease</class>
				<description>
					<field>name</field>
				</description>
			</windowopencontrol> 

			<stringcontrol name="diseaselab">
				<anchored>
					<top>
						<anchor>top</anchor>
						<offset>10</offset>
					</top>
					<right>
						<anchor>right</anchor>
						<offset>-40</offset>
					</right>
					<size>
						<width>45</width>
					</size>
				</anchored>
				<font>statblock-r-med</font>
				<static>Disease</static>
			</stringcontrol>
			<jpgnumberfield name="level">
				<anchored>
					<right>
						<parent>diseaselab</parent>
						<anchor>left</anchor>
					</right>
					<top>
						<parent>diseaselab</parent>
						<anchor>top</anchor>
					</top>
					<size>
						<width>20</width>
					</size>
				</anchored>
				<font>statblock-r-med</font>
				<nodrag />
				<readonly />
			</jpgnumberfield>
			<stringcontrol name="levellab">
				<anchored>
					<right>
						<parent>level</parent>
						<anchor>left</anchor>
					</right>
					<top>
						<parent>diseaselab</parent>
						<anchor>top</anchor>
					</top>
				</anchored>
				<font>statblock-r-med</font>
				<static>Level</static>
			</stringcontrol>

			<stringfield name="name">
				<anchored>
					<top>
						<anchor>top</anchor>
						<offset>10</offset>
					</top>
					<left>
						<anchor>left</anchor>
						<offset>55</offset>
					</left>
					<right>
						<parent>levellab</parent>
						<anchor>left</anchor>
						<offset>-20</offset>
					</right>
				</anchored>
				<font>statblock-b-large</font>
				<static />
			</stringfield>

			<genericcontrol name="contentframe">
				<anchored>
					<top>
						<parent>name</parent>
						<anchor>bottom</anchor>
						<offset>10</offset>
					</top>
					<left>
						<anchor>left</anchor>
					</left>
					<right>
						<anchor>right</anchor>
					</right>
					<bottom>
						<anchor>bottom</anchor>
					</bottom>
				</anchored>
				<frame>
					<name>whitecontrolarea</name>
				</frame>
			</genericcontrol>

			<!-- ATTACK -->
			<genericcontrol name="attackframe">
				<anchored>
					<top>
						<parent>contentframe</parent>
						<anchor>top</anchor>
						<offset>10</offset>
					</top>
					<right>
						<anchor>right</anchor>
						<offset>-10</offset>
					</right>
					<size>
						<height>20</height>
						<width>120</width>
					</size>
				</anchored>
				<frame>
					<name>whitecontrolarea</name>
					<offset>0,3,0,3</offset>
				</frame>
			</genericcontrol>
			<stringcontrol name="atklabel">
				<anchored>
					<top>
						<parent>attackframe</parent>
						<anchor>top</anchor>
						<offset>3</offset>
					</top>
					<right>
						<parent>attackframe</parent>
						<anchor>left</anchor>
						<offset>-10</offset>
					</right>
					<size>
						<height>20</height>
					</size>
				</anchored>
				<right />
				<font>statblock-b-med</font>
				<static>Attack</static>
			</stringcontrol>
			<genericcontrol name="attackicon">
				<anchored>
					<to>attackframe</to>
					<position>insidetopleft</position>
					<offset>5,1</offset>
					<size>
						<height>20</height>
						<width>20</width>
					</size>
				</anchored>
				<icon>d20icon</icon>
				<script>
					function onInit()
						setHoverCursor("hand");
					end
					
					function onDoubleClick(x,y)
						return window.handleDoubleClick();
					end			

					function onDrag(button, x, y, draginfo)
						if dragging then
							return true;
						end
						
						dragging = window.handleDrag(draginfo);
						
						return true;
					end
					
					function onDragEnd(draginfo)
						dragging = false;
					end
				</script>
			</genericcontrol>
			<stringcontrol name="attackview">
				<anchored>
					<left>
						<parent>attackicon</parent>
						<anchor>right</anchor>
						<offset>5</offset>
					</left>
					<top>
						<parent>attackframe</parent>
						<anchor>top</anchor>
						<offset>1</offset>
					</top>
				</anchored>
				<font>statblock-b-large</font>
				<static />
				<script>
					function onInit()
						setHoverCursor("hand");
						update();
					end
					
					function update()
						local powerattacknode = window.getDatabaseNode().getChild("attacks.id-00001");
						local s = "";

						local statval = NodeManager.get(powerattacknode, "attackstat", "");
						if statval ~= "" then
							s = s .. string.upper(string.sub(statval, 1, 1)) .. string.sub(statval, 2, 3);
						end

						local mod = NodeManager.get(powerattacknode, "attackstatmodifier", 0);
						if mod &gt; 0 then
							s = s .. "+" .. mod;
						elseif mod &lt; 0 then
							s = s .. mod;
						elseif s == "" then
							s = s .. "+0";
						end

						local def = NodeManager.get(powerattacknode, "attackdef", "");
						s = s .. " vs. ";
						if def == "ac" then
							s = s .. string.upper(def);
						elseif def == "reflex" then
							s = s .. string.upper(string.sub(def, 1, 1)) .. string.sub(def, 2, 3);
						elseif def ~= "" then
							s = s .. string.upper(string.sub(def, 1, 1)) .. string.sub(def, 2, 4);
						else
							s = s .. "-";
						end
						
						setValue(s);
					end

					function onDoubleClick(x,y)
						return window.handleDoubleClick();
					end			

					function onDrag(button, x, y, draginfo)
						if dragging then
							return true;
						end
						
						dragging = window.handleDrag(draginfo);
						
						return true;
					end
					
					function onDragEnd(draginfo)
						dragging = false;
					end
				</script>
			</stringcontrol>

			<stringfield name="flavor">
				<anchored>
					<top>
						<parent>contentframe</parent>
						<anchor>top</anchor>
						<offset>10</offset>
					</top>
					<left>
						<parent>contentframe</parent>
						<anchor>left</anchor>
						<offset>10</offset>
					</left>
					<right>
						<parent>atklabel</parent>
						<anchor>left</anchor>
						<offset>-20</offset>
					</right>
				</anchored>
				<font>statblock-i-med</font>
				<multilinespacing>20</multilinespacing>
				<selectioncolor>#FFD296</selectioncolor>
			</stringfield>

			<!-- DCs -->
			<genericcontrol name="enduranceframe">
				<anchored>
					<top>
						<parent>attackframe</parent>
						<anchor>bottom</anchor>
						<offset>5</offset>
					</top>
					<right>
						<anchor>right</anchor>
						<offset>-10</offset>
					</right>
					<size>
						<height>35</height>
						<width>120</width>
					</size>
				</anchored>
				<frame>
					<name>whitecontrolarea</name>
					<offset>0,3,0,3</offset>
				</frame>
			</genericcontrol>
			<stringcontrol name="endurancelabel">
				<anchored>
					<top>
						<parent>enduranceframe</parent>
						<anchor>top</anchor>
						<offset>3</offset>
					</top>
					<right>
						<parent>enduranceframe</parent>
						<anchor>left</anchor>
						<offset>-10</offset>
					</right>
					<size>
						<height>20</height>
					</size>
				</anchored>
				<right />
				<font>statblock-b-med</font>
				<static>Endurance</static>
			</stringcontrol>
			<stringcontrol name="stablelab">
				<anchored>
					<to>enduranceframe</to>
					<position>insidetopleft</position>
					<offset>5,2</offset>
					<size>
						<height>15</height>
					</size>
				</anchored>
				<font>statblock-b-med</font>
				<static>Stable DC</static>
			</stringcontrol>
			<jpgnumberfield name="stable">
				<anchored>
					<top>
						<parent>stablelab</parent>
						<anchor>top</anchor>
					</top>
					<right>
						<anchor>right</anchor>
						<offset>-10</offset>
					</right>
					<size>
						<width>25</width>
					</size>
				</anchored>
				<font>statblock-b-med</font>
			</jpgnumberfield>
			<stringcontrol name="improvelab">
				<anchored>
					<to>enduranceframe</to>
					<position>insidetopleft</position>
					<offset>5,20</offset>
					<size>
						<height>15</height>
					</size>
				</anchored>
				<font>statblock-b-med</font>
				<static>Improve DC</static>
			</stringcontrol>
			<jpgnumberfield name="improve">
				<anchored>
					<top>
						<parent>improvelab</parent>
						<anchor>top</anchor>
					</top>
					<right>
						<anchor>right</anchor>
						<offset>-10</offset>
					</right>
					<size>
						<width>25</width>
					</size>
				</anchored>
				<font>statblock-b-med</font>
			</jpgnumberfield>

			<stringfield name="stage000">
				<anchored>
					<top>
						<parent>enduranceframe</parent>
						<anchor>bottom</anchor>
						<offset>10</offset>
					</top>
					<left>
						<parent>flavor</parent>
						<anchor>left</anchor>
					</left>
					<right>
						<parent>flavor</parent>
						<anchor>left</anchor>
						<offset>140</offset>
					</right>
				</anchored>
				<multilinespacing>20</multilinespacing>
				<font>statblock-r-med</font>
				<selectioncolor>#FFD296</selectioncolor>
			</stringfield>
			<stringfield name="stage001">
				<anchored>
					<top>
						<parent>enduranceframe</parent>
						<anchor>bottom</anchor>
						<offset>10</offset>
					</top>
					<left>
						<parent>stage000</parent>
						<anchor>right</anchor>
						<offset>30</offset>
					</left>
					<right>
						<parent>stage000</parent>
						<anchor>right</anchor>
						<offset>170</offset>
					</right>
				</anchored>
				<multilinespacing>20</multilinespacing>
				<font>statblock-r-med</font>
				<selectioncolor>#FFD296</selectioncolor>
			</stringfield>
			<stringfield name="stage002">
				<anchored>
					<top>
						<parent>enduranceframe</parent>
						<anchor>bottom</anchor>
						<offset>10</offset>
					</top>
					<left>
						<parent>stage001</parent>
						<anchor>right</anchor>
						<offset>50</offset>
					</left>
					<right>
						<parent>stage001</parent>
						<anchor>right</anchor>
						<offset>190</offset>
					</right>
				</anchored>
				<font>statblock-r-med</font>
				<multilinespacing>20</multilinespacing>
				<selectioncolor>#FFD296</selectioncolor>
			</stringfield>
			<stringfield name="stage003">
				<anchored>
					<top>
						<parent>enduranceframe</parent>
						<anchor>bottom</anchor>
						<offset>10</offset>
					</top>
					<left>
						<parent>stage002</parent>
						<anchor>right</anchor>
						<offset>30</offset>
					</left>
					<right>
						<parent>stage002</parent>
						<anchor>right</anchor>
						<offset>170</offset>
					</right>
				</anchored>
				<multilinespacing>20</multilinespacing>
				<font>statblock-r-med</font>
				<selectioncolor>#FFD296</selectioncolor>
			</stringfield>

			<genericcontrol name="left1">
				<anchored>
					<left>
						<parent>stage000</parent>
						<anchor>right</anchor>
					</left>
					<top>
						<parent>stage000</parent>
						<anchor>top</anchor>
					</top>
					<size>
						<height>25</height>
						<width>25</width>
					</size>
				</anchored>
				<icon>arrowleft</icon>
			</genericcontrol>
			<genericcontrol name="left2">
				<anchored>
					<left>
						<parent>stage001</parent>
						<anchor>right</anchor>
					</left>
					<top>
						<parent>stage001</parent>
						<anchor>top</anchor>
					</top>
					<size>
						<height>25</height>
						<width>25</width>
					</size>
				</anchored>
				<icon>arrowleft</icon>
			</genericcontrol>
			<genericcontrol name="right1">
				<anchored>
					<left>
						<parent>left2</parent>
						<anchor>right</anchor>
					</left>
					<top>
						<parent>left2</parent>
						<anchor>top</anchor>
					</top>
					<size>
						<height>25</height>
						<width>25</width>
					</size>
				</anchored>
				<icon>arrowright</icon>
			</genericcontrol>
			<genericcontrol name="right2">
				<anchored>
					<left>
						<parent>stage002</parent>
						<anchor>right</anchor>
					</left>
					<top>
						<parent>stage002</parent>
						<anchor>top</anchor>
					</top>
					<size>
						<height>25</height>
						<width>25</width>
					</size>
				</anchored>
				<icon>arrowright</icon>
			</genericcontrol>

			<closebutton />
		</sheetdata>
	</windowclass>
</root>
